package com.ruslan.magaz.domain;
// default package
// Generated 28.09.2014 13:25:18 by Hibernate Tools 3.4.0.CR1

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Digits;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Size;

/**
 * Rating generated by hbm2java
 */
@Entity
@Table(name = "rating", catalog = "eshop")
public class Rating implements java.io.Serializable {

	private int ratingId;
	private User user;
	private Product product;
	@Min(1)
	@Max(5)
	private Short mark;
	@Size(min=2,max=300,message=	"Text must be between 2 and 300 characters.")
	private String reviewText;
	private Date reviewDate;

	

	public Rating() {
	}
	
	public Rating(int ratingId) {
		this.ratingId = ratingId;
	}

	public Rating(int ratingId, User user, Product product) {
		this.ratingId = ratingId;
		this.user = user;
		this.product = product;
	}


	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "Rating_id", unique = true, nullable = false)
	public int getRatingId() {
		return this.ratingId;
	}

	public void setRatingId(int ratingId) {
		this.ratingId = ratingId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "User_id", nullable = false)
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "Product_id", nullable = false)
	public Product getProduct() {
		return this.product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	@Column(name = "Mark")
	public Short getMark() {
		return this.mark;
	}

	public void setMark(Short mark) {
		this.mark = mark;
	}


	@Column(name = "ReviewText", length = 65535)
	public String getReviewText() {
		return this.reviewText;
	}

	public void setReviewText(String reviewText) {
		this.reviewText = reviewText;
	}
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "ReviewDate", length = 19)
	public Date getReviewDate() {
		return this.reviewDate;
	}

	public void setReviewDate(Date reviewDate) {
		this.reviewDate = reviewDate;
	}

}
